function formatTime(date) {
  const year = date.getFullYear();
  const month = date.getMonth() + 1;
  const day = date.getDate();

  const hour = date.getHours();
  const minute = date.getMinutes();
  const second = date.getSeconds();

  return `${[year, month, day].map(date).join('/')} ${[hour, minute, second].map(date).join(':')}`;
}

module.exports = {
  formatTime,
};

const AUTH_TOKEN_KEY = 'auth_token_cache_key';
function getAuthTokenKey() {
  return AUTH_TOKEN_KEY;
}
module.exports.authTokenKey = getAuthTokenKey;


const CAR_KEY = 'car_cache_key';
function getCarKey() {
  return CAR_KEY;
}
module.exports.carKey = getCarKey;

const WX_USER_INFO = 'wx_user_info';
function getWxUserInfoKey() {
  return WX_USER_INFO;
}
module.exports.wxUserInfo = getWxUserInfoKey;

function areaInfo(regid,regionData){
  var data = regionData;//getRegionData();
  var result;
  var i;
  for (i = 0; i < data.length; i++) {
    if (data[i]['regid'] == regid) {
      result = data[i]
    }
  }
  return result;
}
module.exports.areaInfo = areaInfo;

function areaParent(parid,regionData){
  var data = regionData;//getRegionData();
  var result = [];
  var i;
  var ii = 0
  for (i = 0; i < data.length; i++) {
    if (data[i]['parid'] == parid) {
      result[ii] = data[i]
      ii++
    }
  }
  return result;
}
module.exports.areaParent = areaParent;

